<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateContractsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contracts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('advertiser')->comment('公司id');
            $table->string('contract_no')->comment('合同编号')->nullable();
            $table->integer('product_line')->comment('产品线');
            $table->tinyInteger('type')->comment('1普通合同 2媒介合同')->default(1);
            $table->date('start')->comment('开始时间')->nullable();
            $table->date('end')->comment('结束时间')->nullable();
            $table->integer('rebate')->comment('返点')->default(0);
            $table->integer('dl_rebate')->comment('代理返点')->default(0);
            $table->integer('xj_rebate')->comment('现金返点')->default(0);
            $table->decimal('money')->comment('金额')->nullable();
            $table->decimal('show_money')->comment('显示金额')->nullable();
            $table->tinyInteger('pay_type')->comment('付款方式 1预付 2垫付')->default(1);
            $table->text('note')->comment('合同备注')->nullable();
            $table->decimal('back_money')->comment('回款')->default(0);
            $table->decimal('recharge')->comment('续费')->default(0);
            $table->tinyInteger('status')->comment('1正常 2作废 3归档')->default(1);
            $table->integer('mht_id')->comment('媒介合同id')->nullable();
            $table->string('title')->comment('合同标题')->nullable();
            $table->integer('cycle')->comment('回款周期')->default(0);
            $table->integer('flow_id')->comment('审批流id')->nullable();
            $table->integer('order_id')->comment('审批步骤排序id')->default(1);
            $table->integer('flow_user_id')->comment('流程审批人id')->nullable();
            $table->integer('submituser')->comment('提交人');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('contracts');
    }
}
